<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\GoodsModel;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {
        $this->success('请求成功');
    }


    /**
     * 首页文章列表
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @author: zhaoyu
     * @Time: 2024/1/21 12:12
     */
    public function articleIndex()
    {
        $articleModel = new \app\admin\model\articel\Article();
        $articles = $articleModel->where(['is_index' => 1, 'deletetime' => null])
            ->field('id,title,synopsis,image,visit,likes')->order(['sort' => 'desc', 'id' => 'desc'])->limit(3)->select();

        $this->success('获取成功', $articles);
    }

    /**首页商品
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @author: zhaoyu
     * @Time: 2024/1/21 12:25
     */
    public function goodsIndex()
    {
        $goodsModel = new GoodsModel();
        $hotLists = $goodsModel->where(['is_hot' => 1, 'status' => "up", 'deletetime' => 0])
            ->field('id,title,image,price,views,likes,goods_desc')
            ->order(['weigh' => 'desc', 'id' => 'desc'])->limit(6)->select();
        $technologyLists = $goodsModel->where(['is_technology' => 1, 'status' => "up", 'deletetime' => 0])
            ->field('id,title,image,price,views,likes,goods_desc')
            ->order(['weigh' => 'desc', 'id' => 'desc'])->limit(6)->select();
        $this->success('获取成功', compact('hotLists', 'technologyLists'));

    }


    /**
     * 认证服务范围
     * @author: zhaoyu
     * @Time: 2024/1/24 16:07
     */
    public  function  certificationService(){

        $data=[
            [
                'name'=>'产品范围',
                'path'=>'uploads/20240130/renzhengfanwei001.jpg',
            ],
            [
                'name'=>'服务范围',
                'path'=>'uploads/20240130/fuwufanwei001.jpg',
            ],
            [
                'name'=>'产品流程',
                'path'=>'uploads/20240130/renzheng001.jpg',
            ],
            [
                'name'=>'服务流程',
                'path'=>'uploads/20240130/fuwu001.jpg',
            ],
        ];
        $this->success('获取成功', $data);
    }



}
